;;; Nemo file-manager package for GNU Guix.
;;; Copyright © 2021 florhizome <florhizome@posteo.net>
;;;
;;; This file is NOT part of GNU Guix.
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.


(define-module (guixrus packages nemo)
  #:use-module (gnu)
  #:use-module (guix build-system glib-or-gtk)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system meson)
  #:use-module (guix packages)
  #:use-module (guix gexp)
  #:use-module (guix build utils)
  #:use-module (guix utils)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages)
  #:use-module (gnu packages build-tools)
  #:use-module (gnu packages base)
  #:use-module (gnu packages file)
  #:use-module (gnu packages photo)
  #:use-module (gnu packages freedesktop)
  #:use-module (gnu packages gcc)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages xorg)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages xdisorg)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages pantheon)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages python)
  #:use-module (gnu packages wm)
  #:use-module (gnu packages libcanberra)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages autogen)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages cmake)
  #:use-module (gnu packages cinnamon)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages libffi)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages icu4c)
  #:use-module (gnu packages sqlite))

(define-public cinnamon-desktop-5.2
  (package
    (inherit cinnamon-desktop)
    (name "cinnamon-desktop-5.2")
    (version "5.2.0")
    (source
     (origin
       (method git-fetch)
       (uri
        (git-reference
         (url "https://github.com/linuxmint/cinnamon-desktop/")
         (commit version)))
       (sha256
        (base32 "106py9vgvax29y21pp662i8dxkg0k6chnq1sfk5kj1p3q6cm5sc0"))))
    (build-system meson-build-system)
    (native-inputs
     (append
      (package-native-inputs cinnamon-desktop)
      `(("gobject-introspection" ,gobject-introspection)
        ("intltool" ,intltool))))))

;;;TODO build with tracker support
(define-public nemo
  (package
    (name "nemo")
    (version "5.2.3")
    (source
     (origin
      (method git-fetch)
      (uri
       (git-reference
        (url "https://github.com/linuxmint/nemo")
        (commit version)))
      (sha256
       (base32 "1x3ir47g11q9r56fgyh1mqwmx4kis2ixcikjqy884zwdr1cp1z4h"))))
    (build-system meson-build-system)
    (arguments
     `(#:glib-or-gtk? #t
       #:meson ,meson-0.59
       ;;TODO, doesn't work, trackersparql deps not found
       ;;#:configure-flags '("-Dtracker=true")
       #:tests? #f ;;tests fail with: cannot find display
       #:phases
       (modify-phases %standard-phases
                      (add-after 'patch-source-shebangs 'adjust-prefix
                                 (lambda*
                                     (#:key outputs #:allow-other-keys)
                                   (let ((out (assoc-ref outputs "out")))
                                     (substitute*
                                      (find-files "meson.build")
                                      (("'data_dir")
                                       (string-append "'" out "/share"))))
                                                           #t)))))
    (native-inputs
     (list pkg-config `(,gtk+ "bin") gettext-minimal intltool
           `(,glib "bin") gobject-introspection))
    (inputs
     (list libnotify libxml2 gsettings-desktop-schemas
           libgsf libx11
           gtk+
           cinnamon-desktop-5.2
           xkeyboard-config
           libxkbfile
           xapp
           libexif
           exempi
           atk))
    (home-page "https://github.com/linuxmint/nemo")
    (synopsis "File browser for Cinnamon")
    (description "Nemo is the file manager for the Cinnamon desktop
 environment.")
    (license license:expat)))

(define-public xapp
  (package
   (name "xapp")
   (version "2.2.8")
   (source
    (origin
     (method git-fetch)
     (uri
      (git-reference
       (url "https://github.com/linuxmint/xapp.git")
       (commit version)))
     (sha256
      (base32 "0ghryqlf7a3w2l215spx8kyrghw5ximsqj1h39qyx5m426hnnjzg"))))
   (build-system meson-build-system)
   (arguments
    `(#:glib-or-gtk? #t
      #:phases
      (modify-phases
       %standard-phases
       (add-after 'patch-source-shebangs 'adjust-prefix-in-configure
                  (lambda* (#:key outputs #:allow-other-keys)
                    (let ((out (assoc-ref outputs "out")))
                      (substitute*
                       "./libxapp/meson.build"
                       (("gtk3_dep\\.get_pkgconfig_variable\\('libdir'\\)")
                        (string-append "'" out "/lib'")))
                      (substitute*
                       "./pygobject/meson.build"
                       (("override_dir,")
                        (string-append
                         "'" out
                         "/lib/python3.8/site-packages/gi/overrides',")))
                      #t))))))
   (propagated-inputs (list libgnomekbd))
   (native-inputs (list pkg-config
                        gettext-minimal
                        gobject-introspection
                        libxml2
                        vala `(,glib "bin")))
   (inputs
    (list python-pygobject
          glib
          gtk+
          gnome-menus
          libdbusmenu
          libgnomekbd
          atk))
   (home-page "https://github.com/linuxmint/xapp")
   (synopsis "Cross-desktop libraries and common resources")
   (description "This project gathers the components which are common to
multiple GTK desktop environments (Cinnamon, MATE and Xfce) and
 required to implement cross-DE solutions.")
   (license license:expat)))
